package Jw20241025;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description: HashMap——统计单词出现次数
 * User: 王圆豪
 * Date: 2024-10-25
 * Time: 21:45
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = "";
        while(sc.hasNext()){
            String s1 = sc.next();
            if (!Objects.equals(s1, " ")) {
                s = s + " " + s1;
            }
        }
        args = s.split(" ");
        HashMap<String, Integer> hashMap = Statistics(args);
    }

    private static HashMap<String, Integer> Statistics(String[] args) {
        HashMap<String, Integer> hashMap = new HashMap<>();
        for (String arg : args) {
            if (!hashMap.containsKey(arg)) {
                hashMap.put(arg, 1);
            } else {
                for (Map.Entry<String, Integer> entry :
                        hashMap.entrySet()) {
                    if (Objects.equals(entry.getKey(), arg)) {
                        entry.setValue(entry.getValue() + 1);
                    }
                }
            }
        }
        return hashMap;
    }
}
